// pages/admin-nav/admin-nav.js
Page({
    data: {
      currentUser: {}, // 当前登录用户
    },
  
    onLoad() {
      const currentUser = wx.getStorageSync('currentUser');
      if (currentUser && currentUser.role === 'admin') {
        this.setData({ currentUser });
      } else {
        wx.showToast({
          title: '权限不足',
          icon: 'none',
          duration: 1500,
        });
  
        setTimeout(() => {
          wx.reLaunch({
            url: '/pages/login/login',
          });
        }, 1500);
      }
    },
  
    navigateToAddItem() {
      wx.navigateTo({
        url: '/pages/add-item/add-item',
      });
    },
  
    navigateToBorrowHistory() {
      wx.navigateTo({
        url: '/pages/history/history',
      });
    },
  
    navigateToInventory() {
      wx.navigateTo({
        url: '/pages/inventory/inventory',
      });
    },
  
    navigateToAddUser() {
      wx.navigateTo({
        url: '/pages/user-add/user-add',
      });
    },
  
    navigateToBorrow() {
      wx.navigateTo({
        url: '/pages/borrow/borrow',
      });
    },


    navigateToBorrowManage() {
        wx.navigateTo({
          url: '/pages/borrowManage/borrowManage',
        });
      },

  });